<?php
/**
 * Created by PhpStorm.
 * User: 94004
 * Date: 2017/12/30
 * Time: 20:03
 */
header("Content-Type:text/html;charset=utf-8;");
require_once "../util/db_helper.php";
$currentPage = $_POST["currentPage"];
$pageCount = $_POST["pageCount"];
$offset = ($currentPage - 1) * $pageCount;
$sql = " SELECT * FROM comments c ";
$sql .= " LIMIT {$offset},$pageCount ";
$res = query($sql);
$countSql = " SELECT COUNT(*) AS dataCount FROM comments c ";
$countRes = query($countSql);
$arr = array("code" => 101, "msg" => "操作失败");
if ($res) {
    $arr["code"] = 100;
    $arr["msg"] = "操作成功";
    $arr["data"] = $res;
    $arr["dataCount"] = $countRes[0]["dataCount"];
}
echo json_encode($arr, JSON_UNESCAPED_UNICODE);
?>